<?php

namespace Transform;

class UserTransform extends Transform
{
    public function details($arguments)
    {
        return [
            'allows' => ['user_id','email','account','token','username', 'mobile','money','coin', 'nickname','birthday','sex','face','city','score','intro','age','is_cert','relation','empty_password','pay_password','is_needverify','is_add_by_mobile','is_add_by_uid','is_add_by_group','is_add_by_qrcode','is_add_by_uesrinfo'
                ],
        ];
    }

    public function wallet()
    {
        return [
            'allows' => ['money', 'coin', 'withdrawable_money'],
        ];
    }

    /**
     * 只保留不变的属性，一般用于token
     *
     * @return void
     */
    public function token($arguments)
    {
        return [
            'allows' => ['user_id', 'account','token'],
            'iat' => ['value' => time()],
            // 有效时间为7天
            'exp' => ['value' => time() + 3600 * 24 * 7],
        ];
    }

    /**
     * 公开
     *
     * @return void
     */
    public function pub($argements)
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 
                'role', 'is_like', 'is_blocked', 
                'level', 'intro', 'pro_intro', 'followers_count', 'following_count', 
                'posts_count', 'praises_count', 'lv_anchor', 'answer_price', 'star',
                'contribution', 'answers_count', 'age','nationality'],
        ];
    }

    public function anchor()
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 'role', 
                'is_like', 'is_blocked', 'level', 'intro', 'pro_intro', 'followers_count', 
                'following_count', 'posts_count', 'praises_count', 'lv_anchor', 'answer_price', 
                'star', 'contribution', 'answers_count', 'age', 'tags'],
            'tags' => [
                'trans' => ['name' => 'LiveTag', 'method' => 'pub'],
            ]
        ];
    }

    public function specialist($argements)
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 'role', 'is_like', 'is_blocked', 'level', 'intro', 'pro_intro', 'followers_count', 'following_count', 'posts_count', 'praises_count', 'lv_anchor', 'answer_price', 'star', 'contribution', 'answers_count', 'age', 'is_online'],
        ];
    }

    public function simple()
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'face', 'city'],
            'user_id' => ['alias' => 'uid'],
            'face' => ['alias' => 'headpic'],
        ];
    }

    public function liveViewer()
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 'role', 'is_like', 'is_blocked', 'level', 'intro', 'pro_intro', 'is_admin', 'followers_count', 'following_count', 'posts_count', 'praises_count', 'lv_anchor', 'answer_price', 'star', 'contribution', 'answers_count', 'age', 'score'],
        ];
    }

    public function starRankList()
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 'role', 'is_like', 'is_blocked', 'level', 'intro', 'pro_intro', 'star_rank', 'lv_anchor', 'answer_price', 'star', 'contribution', 'answers_count', 'age', 'score'],
            'star_rank' => ['type' => 'int'],
        ];
    }
    
    public function contributionRankList()
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 'role', 'is_like', 'is_blocked', 'level', 'intro', 'pro_intro', 'contribution_rank', 'lv_anchor', 'answer_price', 'star', 'contribution', 'answers_count', 'age', 'score'],
            'contribution_rank' => ['type' => 'int'],
        ];
    }

    public function followerRankList()
    {
        return [
            'allows' => ['user_id', 'nickname', 'birthday', 'sex', 'face', 'city', 'role', 'is_like', 'is_blocked', 'level', 'intro', 'pro_intro', 'followers_count', 'lv_anchor', 'answer_price', 'star', 'contribution', 'answers_count', 'age', 'score'],
            'followers_count' => ['type' => 'int'],
        ];
    }
}
